///<reference path="../../../../libs/proto/protolist.d.ts"/>
/**
 * Created by PengWei on 2017/10/11.
 */
namespace game {
    import FeteProtoReward = protolist.FeteProtoReward;
    import GObject = fairygui.GObject;
    import DisplayObject = egret.DisplayObject;
    import IItemProtoInfo = protolist.IItemProtoInfo;
    import ItemProtoInfo = protolist.ItemProtoInfo;

    export class ResourceManager {
        public static readonly URL_SILVER: string = "ui://p1at7pemo4r63k";
        public static readonly URL_GOLD: string = "ui://p1at7pemo4r63m";
        public static readonly URL_ATK: string = "ui://p1at7pemyaxw4d";
        public static readonly URL_DEF: string = "ui://p1at7pemyaxw4e";
        public static readonly URL_HP: string = "ui://p1at7pemyaxw4g";
        public static readonly URL_SPD: string = "ui://p1at7pemyaxw4f";
        public static readonly URL_CRT: string = "ui://p1at7pemqrr76p";
        public static readonly URL_RESIST: string = "ui://p1at7pemjoce6o";
        public static readonly URL_HIT: string = "ui://p1at7pemjoce6n";
        public static readonly URL_DOD: string = "ui://p1at7pemqrr76q";
        public static readonly URL_WATCH: string = "ui://2e6kvoq0u43lah";
        public static readonly URL_DROP_CRT: string = "ui://2e6kvoq0xb8cmdo";
        public static readonly URL_FOOD: string = "ui://p1at7pemo4r63l";
        public static readonly URL_FOOD_TOKEN: string = "ui://2e6kvoq0jwvfkmf9";
        public static readonly URL_BUSINESS: string = "ui://p1at7pemo4r61t";
        public static readonly URL_SECURITY: string = "ui://p1at7pemo4r61u";
        public static readonly URL_TREASURE_MAP: string = "ui://2e6kvoq0ti0tkmha";//藏宝图
        public static readonly URL_SLICE: string = "ui://p1at7pemyaxw4h";//碎片图标
        public static readonly URL_HANXIANDI: string = "ui://2e6kvoq0dfhgkme7";//汉献帝图标
        public static readonly URL_DEVOTION: string = "ui://2e6kvoq0p21wd9";//玉钱
        public static readonly URL_SET: string = "ui://2e6kvoq0r9jj8e";//设置图标
        public static readonly URL_FRIEND: string = "ui://p1at7pemo4r62u";//好友图标
        public static readonly URL_SPEED: string = "ui://p1at7pemhoty5a";//加速图标
        public static readonly URL_END: string = 'ui://p1at7pemhoty5b';//结束图标
        public static readonly URL_WARBOOK: string = "icon_34_png";//兵书
        public static readonly URL_TICKET: string = "ui://2e6kvoq0k4ujkmnx";//门票
        public static readonly URL_FORMAT: string = "ui://p1at7pemo4r62e";//阵型;
        public static readonly URL_BLUE_CIRCLE_BG: string = "ui://2e6kvoq0r5cukmg9";//蓝光圈底
        public static readonly URL_BLUE_CIRCLE_BODY: string = "ui://2e6kvoq0r5cukmga";//蓝光圈身体
        public static readonly URL_ENERGY: string = "ui://p1at7pemlrgw6l";//体力
        public static readonly URL_LEAGUE_POINT: string = "ui://p1at7pemh8je73"; // 武神赛积分
        public static readonly URL_FAMOUS_REWARD: string = "ui://2e6kvoq0iytj88"; // 朝廷嘉奖
        public static readonly URL_LBC: string = "ui://2e6kvoq0iytj88"; // 练兵场
        public static readonly URL_VS: string = "ui://2e6kvoq0cd6lkmq3"; // VS图标
        public static readonly URL_REWARD_BOX: string = "ui://2e6kvoq0mhmhkmqo"; // 宝箱图标

        static readonly CITY_1 = 'ui://2e6kvoq0nuimbz';
        static readonly CITY_2 = 'ui://2e6kvoq0nuimc0';
        static readonly CITY_3 = 'ui://2e6kvoq0nuimc1';

        public constructor() {

        }

        public static init() {
            this._res_map = new HashMap<string, number>();
            this._res_map.set("diamond", ResType.diamond);
            this._res_map.set("sysDiamond", ResType.sysDiamond);
            this._res_map.set("resource", ResType.resource);
            this._res_map.set("treasure", ResType.treasure);
            this._res_map.set("hero", ResType.hero);
            this._res_map.set("watch", ResType.watch);
            this._res_map.set("effectSp", ResType.effectSp);
            this._res_map.set("visit", ResType.visit);
            this._res_map.set("offend", ResType.offend);
            this._res_map.set("honor", ResType.honor);
            this._res_map.set("devotion", ResType.devotion);
            this._res_map.set("worldExp", ResType.worldExp);
            this._res_map.set("defendToken", ResType.defendToken);
            this._res_map.set("food", ResType.food);
            this._res_map.set("wood", ResType.wood);
            this._res_map.set("itemShop", ResType.worldShopItem);
            this._res_map.set("business", ResType.business);
            this._res_map.set("security", ResType.security);
            this._res_map.set("treasureMap", ResType.treasureMap);
            this._res_map.set("recoveryFood", ResType.recoveryFood);
            this._res_map.set("circlePoint", ResType.circlePoint);
            this._res_map.set("effectDan", ResType.effectDan);
            this._res_map.set("equip", ResType.Equip);
            this._res_map.set("leaguePoint", ResType.leaguePoint);
            this._res_map.set("seniorFeteTimes", ResType.seniorFeteTimes);

            let newItemAccessInfoMap = new Map<number, ItemInfo>();
            StaticData.Instance.itemInfoMap.forEach((value, key, map) => {
                newItemAccessInfoMap.set(value.itemType * 10000 + value.itemId, value);
                if (!this._res_map.hasByKey(value.itemTypeDesc))
                    this._res_map.set(value.itemTypeDesc, value.itemType);
            }, this);

            StaticData.Instance.itemInfoMap = newItemAccessInfoMap;
        }

        public static createCustomerVO(url: string, name: string, count: number, color?: number, type?: number) {
            let item = this.createCustomerItem(url, name);
            let res = new ResVO();
            res.item = item;
            res.name = name;
            res.count = count;
            if (color) res.color = color;
            if (type) res.item.itemType = type;
            return res;
        }

        public static createCustomerItem(url: string, name: string) {
            let item: ItemInfo = new ItemInfo();
            item.resourceId = url;
            item.itemName = name;
            return item;
        }

        private static _res_map: HashMap<string, number>;


        public static getCount(type: ResType, id: number = 0) {
            // let playerModule = PlayerModule.instance;
            // switch (type) {
            //     case ResType.resource:
            //         return playerModule.getResource(id).num;
            //     case ResType.diamond:
            //         return this.gold;
            //     case ResType.wood:
            //         return playerModule.roleInfo.wood;
            // }
            return 0;
        }

        public static getHeroFullUrl(id): string {
            return 'hero_full_' + id + '_png';
        }

        public static getHeroFullSmallUrl(id): string {
            return 'hero_full_s_' + id + '_png';
        }

        public static hasEnough(require: number, type: ResType, warn: boolean = true, id: number = 0): boolean {
            let own = this.getCount(type, id);
            let out = own >= require;
            if (warn && !out) {
                let item = this.getStaticItemByTypeId(type, id);
                if (item) {
                    // Dispatcher.Instance.showMessage(`${item.itemName}不足`, Color.MSG_RED);
                }
            }
            return out;
        }

        public static getStaticItemByTypeId(type: number, id: number): ItemInfo {
            if (!type) return null;
            id = parseInt(id.toString());
            type = parseInt(type.toString());
            let key: number = type * 10000 + id;
            if (StaticData.Instance.itemInfoMap.has(key))
                return StaticData.Instance.itemInfoMap.get(key);
            let item: ItemInfo = new ItemInfo({
                id: 0,
                itemType: type,
                itemTypeDesc: this._res_map.getKeyByValue(type),
                itemId: id
            });
            item.itemType = type;
            switch (type) {
                case ResType.devotion:
                    item = StaticData.Instance.itemInfoMap.get(type * 10000);
                    item.itemId = id;
                    break;
                case ResType.worldShopItem:
                    let worldShop: WorldShop = StaticDataUtils.getDataById(WorldShop, id);
                    let cfgStr = worldShop.reward;
                    let cfgSplit = cfgStr.split(":");
                    let A_type = cfgSplit.shift();
                    cfgSplit.shift();
                    cfgSplit.shift();
                    cfgSplit.shift();
                    let E_id = cfgSplit.length ? cfgSplit.shift() : 0;
                    return this.getStaticItemByTypeId(this._res_map.getValueByKey(A_type), parseInt(E_id.toString()));
                case ResType.treasure:
                    let treasure = ArrayUtils.getFromMap(StaticData.Instance.treasureMap, ["treasureId", id]);
                    item.itemName = treasure.name;
                    item.resourceId = ResourceManager.getTreasureIconUrl(treasure.treasureId, false);
                    break;
                case ResType.Equip:
                    let equip = StaticDataUtils.getDataById(Equip, id);
                    item.itemName = equip.name;
                    item.resourceId = equip.pic;
                    item['quality'] = equip.quality;
                    item.classify = '1';//装备在背包可见
                    item.inBag = 1;
                    break;
                case ResType.hero:
                    let hero = StaticData.Instance.heroInfoMap.get(id);
                    item.itemName = hero.name;
                    item.resourceId = ResourceManager.getHeroIconUrl(hero.id, false);
                    item['quality'] = hero.quality;
                    break;
                case ResType.seniorFeteTimes:
                    item.itemName = '免费十连宴';
                    item.resourceId = 'bar_3_png';
                    item['quality'] = 5;
                    break;
                case ResType.seniorOnceFeteTimes:
                    item.itemName = '免费宴请';
                    item.resourceId = 'bar_2_png';
                    item['quality'] = 5;
                    break;
                case ResType.effectSp:
                    let effectCfg: HeroEffectInfoClient = StaticDataUtils.getDataById(HeroEffectInfoClient, id);
                    item.itemName = effectCfg.name;
                    item.resourceId = ResourceManager.getSkillIconUrl(id, false);
                    break;
                case ResType.teamNum:
                    item.resourceId = ResourceManager.getWorldShopIconUrl(3, false);
                    break;
                case ResType.destroy:
                    // let buildingName;
                    // switch(id)// 1城门 2名将 3组队副本建筑
                    // {
                    //     case 1:
                    //         buildingName = "城门";
                    //         break;
                    //     case 2:
                    //         buildingName = "酒馆";
                    //         break;
                    //     case 3:
                    //         buildingName = "兵营";
                    //         break;
                    // }
                    // item.itemName = "摧毁" + buildingName;
                    item.resourceId = "resource/assets/scene/building_d.png";
                    break;
                case ResType.doubleEquipUp:
                    item.resourceId = this.URL_DROP_CRT;
                    break;
                case ResType.copperFlag:
                    item.resourceId = this.URL_SILVER;
                default:
                    key = type * 10000 + 0;
                    if (StaticData.Instance.itemInfoMap.has(key))
                        return StaticData.Instance.itemInfoMap.get(key);
                    return null;
            }
            StaticData.Instance.itemInfoMap.set(key, item);
            return item;
        }

        public static getIconUrl(res: string) {
            if (res.indexOf("ui://") >= 0)
                return res;
            if (res == "icon_1")
                return this.URL_GOLD;
            if (res == "icon_2")
                return this.URL_SILVER;
            if (res == "icon_8")
                return this.URL_WATCH;
            if (res == "icon_12")
                return this.URL_FRIEND;
            if (res == "icon_17")
                return this.URL_FOOD;
            if (res == "icon_19")
                return this.URL_BUSINESS;
            if (res == "icon_20")
                return this.URL_SECURITY;
            if (res == "icon_21")
                return this.URL_TREASURE_MAP;
            if (res == "icon_41")
                return this.URL_TICKET;
            if (res == "icon_league_point")
                return this.URL_LEAGUE_POINT;
            if (res.indexOf('.') > 0)
                return res;
            if (res.indexOf('_png') < 0 && res.indexOf("resource/assets/") == -1)
                return "resource/assets/icon/" + res + ".png";
            return res;
        }

        public static getMusicUrl(music: string) {
            return "resource/music/" + music + ".mp3";
        }

        public static getShortSound(s) {
            return s + "_mp3";
        }

        public static getShortPng(s) {
            return s + "_png"
        }

        public static getSoundUrl(sound: string) {
            return "resource/sound/" + sound + ".mp3";
        }

        public static getUIAsyncUrl(url: string) {
            return "resource/assets/uiAsync/" + url + ".png";
        }

        public static getSkillIconUrl(skillId: number, full: boolean = true) {
            let out = 'skill_' + skillId;
            if (full) {
                out = "resource/assets/icon/" + out + ".png";
            }
            return out;
        }

        public static getEquipIconUrl(type, pos) {
            return "resource/assets/icon/equip_" + type + "_" + pos + ".png";
        }

        public static getTechIconUrl(id) {
            return "resource/assets/icon/tech_" + id + ".png";
        }

        public static getMonsterIconUrl(heroId, full: boolean = true) {
            let out = "monster_" + heroId;
            if (full)
                out = "resource/assets/icon/" + out + ".png";
            return out
        }

        public static getHeroIconUrl(heroId, full: boolean = true) {
            if (full)
                return "resource/assets/icon/hero_" + heroId + ".png";
            return "hero_" + heroId;
        }

        public static getAvatarIconUrl(avatarId) {
            return `avatar_${avatarId}_png`
            // if(full)
            //     return "resource/assets/icon/avatar_" + avatarId + ".png";
            // return "avatar_" + avatarId;
        }

        public static getWorldShopIconUrl(id: number, full: boolean = true) {
            if (full)
                return "resource/assets/icon/shop_" + id + ".png";
            return "shop_" + id;
        }

        public static getTreasureIconUrl(treasureId: number, full: boolean = true) {
            if (full)
                return "resource/assets/icon/treasure_" + treasureId + ".png";
            return "treasure_" + treasureId;
        }

        public static getSceneUrl(res: string) {
            if (res.indexOf("/") == -1)
                return "resource/assets/scene/" + res + ".png";
            return res;
        }

        /**
         * 掉落格式：
         * A:B:C:D:E:F:G
         * A 掉落物品标识
         * B 1.组合掉落  2.独立掉落
         * C B填1时表示权重； B填2时表示掉落概率
         * D 整数型数量
         * E id或类型 （具有唯一性的资源可不填，如钻石、秒表）
         * F 0,整片   1，碎片
         * G 0，不可超上限 1，可超上限 （默认0）
         * @param cfgStr
         * @returns {game.ResVO}
         */
        public static parseItemCfg(cfgStr: string) {
            let cfgSplit = cfgStr.split(":");
            let A_type = cfgSplit.shift();
            let B = parseInt(cfgSplit.shift());
            let C = parseInt(cfgSplit.shift());
            let D_count = cfgSplit.shift();
            let E_id = cfgSplit.length ? parseInt(cfgSplit.shift()) : 0;
            let F_sp = cfgSplit.length ? parseInt(cfgSplit.shift()) : 0;
            let G = cfgSplit.length ? parseInt(cfgSplit.shift()) : 0;

            let cfgResType = this._res_map.getValueByKey(A_type);
            let vo = new ResVO();
            vo.item = this.getStaticItemByTypeId(cfgResType, E_id);
            if (vo.item) {
                vo.name = vo.item.itemName;
                if (vo.item['quality'])
                    vo.quality = vo.item['quality'];
            }
            vo.isRandomDrop = B == 1 || C != 1000;
            vo.count = parseInt(D_count);
            vo.isSp = F_sp == 1 ? true : false;
            return vo;
        }

        public static getItemCfgAmongList(cfgList, filterType) {
            let cfgSplit = cfgList.split(";");
            for (let singleList of cfgSplit) {
                let vo = this.parseItemCfg(singleList);
                if (vo.item.itemType == filterType)
                    return vo;
            }
            return null;
        }

        public static getIntimacyResVO() {
            let resVO = new ResVO();
            resVO.item = new ItemInfo();
            resVO.name = "亲密度";
            resVO.count = 1;
            return resVO;
        }

        public static showReward(list: any[], target?: DisplayObject | GObject | egret.Point, offsetX: number = 0, offsetY: number = -100, scale: number = 0.8) {
            // let rewardList;
            // if (list && list.length && (!(list[0] instanceof ResVO)))
            //     rewardList = this.parseResListByItemList(list);
            // else
            //     rewardList = list;
            // let pt = target ?
            //     ((target instanceof Point) ? target : target.localToGlobal(target.width / 2 + offsetX, offsetY))
            //     : new Point(GameConfig.StageWidth / 2 + offsetX, GameConfig.StageHeight / 2 + offsetY);
            // let delay = 0;
            // for (let reward of rewardList) {
            //     ItemFly.Create(reward, pt.clone(), null, null, delay, scale);
            //     delay += 100;
            // }
        }

        public static showRewardUI(reward: string| ResVO | ResVO[] | ItemProtoInfo | ItemProtoInfo[] | IItemProtoInfo | IItemProtoInfo[], desc: string = null,callback:Function = null,callbackObj:any = null) {
            if(callback && callbackObj)callback.bind(callbackObj);
            // let data = CommonRewardUIData.Create(reward, desc,callback);
            // Dispatcher.Instance.dispatchUIEventWith(UIEvent.OPEN, UIType.CommonReward, data);
        }

        public static parseResByItemProto(itemInfo: IItemProtoInfo, ...filters) {
            let item = this.getStaticItemByTypeId(itemInfo.type, itemInfo.itemId ? itemInfo.itemId : 0);
            if (item) {
                if (!filters || !filters.length || filters.indexOf(item.itemType) >= 0) {
                    let resVo = new ResVO();
                    resVo.item = item;
                    resVo.name = itemInfo.name;
                    resVo.count = itemInfo.num;
                    resVo.quality = item["quality"];
                    if (itemInfo.type == ResType.treasureMap) {//藏宝藏默认为碎片
                        resVo.isSp = true;
                    } else {
                        resVo.isSp = itemInfo.sp == 1;
                    }
                    resVo.countTxt = TextUtil.FormatNumTxt(resVo.count);
                    if (itemInfo.num == 0)
                        resVo.description = resVo.name + "已达上限";
                    return resVo;
                }
            }
            return null;
        }

        public static parseResListByItemList(list: any[], ...filters) {
            if (!list) return [];
            let returnValue: ResVO[] = [];
            for (let i = 0; i < list.length; i++) {
                let itemObj = list[i];
                let itemInfo: IItemProtoInfo;
                if (itemObj instanceof FeteProtoReward)
                    itemInfo = itemObj.rewardList[0] as IItemProtoInfo;
                else
                    itemInfo = itemObj;
                if (!itemInfo) continue;
                if (itemInfo.type == ResType.honor) continue;

                let resVO = this.parseResByItemProto(itemInfo, ...filters);
                if (resVO)
                    returnValue.push(resVO);
            }
            return returnValue;
        }

        public static parseResListByStr(cfgStr, ...filters) {
            let splitter = cfgStr.split(";");
            let returnValue: ResVO[] = [];
            for (let i = 0; i < splitter.length; i++) {
                let resVo = this.parseItemCfg(splitter[i]);
                if (resVo.item && resVo.item.itemType == ResType.honor) continue;
                if (resVo.item) {
                    if (resVo.count > 1 && resVo.isSp == false && resVo.item.itemType == ResType.hero)
                        resVo.count = 1;
                    if (!filters || !filters.length || filters.indexOf(resVo.item.itemType) >= 0) {
                        resVo.countTxt = TextUtil.FormatNumTxt(resVo.count);
                        returnValue.push(resVo);
                    }
                }
            }
            return returnValue;
        }

        public static parseTreasureCost(costStr) {
            let res = this.parseItemCfg(costStr);
            return res.count;
        }

        // public static get silver() {
            // let playerModule = PlayerModule.instance;
            // return playerModule.getResource(ResId.silver).num;
        // }

        static isSilver(item: ItemInfo) {
            return item.itemType == ResType.resource && item.itemId == ResId.silver;
        }

        // public static getEffectDanNum(type: number) {
        //     let playerModule = PlayerModule.instance;
        //     let effectDan = playerModule.roleInfo.effectDan;
        //     if (!effectDan.length) return 0;
        //     return parseInt(effectDan.split(';')[type]);
        // }

        // public static get devotion() {
        //     let playerModule = PlayerModule.instance;
        //     return playerModule.roleInfo.devotion;
        // }

        // public static get gold() {
        //     let playerModule = PlayerModule.instance;
        //     return playerModule.me.scRole.diamond;
        // }

        // public static consumeFood(costFood, callback: Function, callbackObj: any, failCallback?: Function) {
        //     let ownFood = FoodModel.Instance.foodInfo.food;
        //     let hasRecover = FoodModel.Instance.hasRecover;
        //     if (ownFood < costFood || costFood < 0 || (!hasRecover)) {
        //         if (failCallback) failCallback.apply(callbackObj);
        //         Consume.buyFood();
        //     } else {
        //         if (callback)
        //             callback.apply(callbackObj);
        //     }
        // }

        public static getCost(costStr) {
            return this.parseItemCfg(costStr).count;
        }

        // public static isEnough(cost: string | ResVO, popNotEnoughTip: boolean = false) {
        //     let resVO = cost instanceof ResVO ? cost : this.parseItemCfg(cost);
        //     let ownCount;
        //     let roleInfo = PlayerModule.instance.roleInfo;
        //     switch (resVO.item.itemType) {
        //         case ResType.diamond:
        //         case ResType.sysDiamond:
        //             ownCount = roleInfo.diamond;
        //             break;
        //         case ResType.resource:
        //             ownCount = PlayerModule.instance.getResource(resVO.item.itemId).num;
        //             break;
        //         case ResType.honor:
        //             ownCount = roleInfo.honor;
        //             break;
        //         case ResType.watch:
        //             ownCount = roleInfo.watchNum;
        //             break;
        //         case ResType.devotion:
        //             ownCount = roleInfo.devotion;
        //             break;
        //         case ResType.defendToken:
        //             ownCount = roleInfo.defendToken;
        //             break;
        //         default:
        //             ownCount = BagModel.Instance.getCount(resVO.item.itemType)
        //     }
        //
        //     let returnValue = ownCount >= resVO.count;
        //     if (!returnValue && popNotEnoughTip) {
        //         Dispatcher.Instance.dispatchEventWith(UIEvent.SHOW_MESSAGE, false, {msg: TextUtil.Format('{0}不足', resVO.item.itemName)})
        //     }
        //
        //     return returnValue;
        // }

        static getCityIcon(type: number) {
            if (type == 1) {
                return ResourceManager.CITY_1;
            } else if (type == 2) {
                return ResourceManager.CITY_2;
            } else {
                return ResourceManager.CITY_3;
            }
        }

        static getBarIconUrl(idx: number) {
            return "bar_" + idx + "_png";
        }

    //     static getHeroAttributeUrl(attribute: string) {
    //         switch (attribute) {
    //             case HeroAttribute.AP:
    //                 return this.URL_ATK;
    //             case HeroAttribute.DP:
    //                 return this.URL_DEF;
    //             case HeroAttribute.HP:
    //                 return this.URL_HP;
    //             case HeroAttribute.SP:
    //                 return this.URL_SPD;
    //             case HeroAttribute.CRIT_RATE:
    //                 return this.URL_CRT;
    //             case HeroAttribute.RESIST:
    //                 return this.URL_RESIST;
    //             case HeroAttribute.HIT:
    //                 return this.URL_HIT;
    //             case HeroAttribute.DODGE:
    //                 return this.URL_DOD;
    //         }
    //     }
    }

    export enum ResType {
        diamond = 1,
        sysDiamond = 2,
        resource = 3,
        resourceMax = 4,
        resource_velocity = 5,
        build = 6,
        hero = 7,
        player_exp = 8,
        formation = 9,
        gov = 10,
        report = 11,
        treasure_open = 12,
        treasure = 13,
        intimacy = 14,
        circlePoint = 18,
        watch = 20,
        effectSp = 25,
        offend = 27,
        visit = 28,
        honor = 29,
        worldOpen = 30,
        destroy = 31,
        devotion = 32,
        worldExp = 33,
        defendToken = 34,
        doubleEquipUp = 40,
        food = 42,
        recoveryFood = 43,
        wood = 45,
        teamNum = 46,
        business = 47,
        security = 48,
        foodLv = 49,
        treasureMap = 50,
        seniorFeteTimes = 52,
        quickFightToken = 56,
        effectDan = 60,
        foodToken = 62,
        teamNumToken = 63,
        moneyTreeToken = 64,
        warBook = 66,
        morale = 68,
        armySpirit = 69,
        wine = 77,
        bagMax = 78,
        onlineBonusRatio = 79,
        luckyBag = 80,
        heroCollection = 81,
        trialBuyTimes = 82,
        matchTicket = 84,
        moraleBuyTimes = 85,
        matchOpen = 86,
        HeroSplitExchange = 87,
        TrialTicket = 88,
        TrailScore = 89,
        Energy = 95,
        Equip = 96,
        leagueTicket = 106,
        animate = 110,
        leaguePoint = 111,
        equipBox = 113,
        stepDan = 114,
        copperFlag = 125,
        seniorOnceFeteTimes = 126,
        worldShopItem = 500
    }

    export enum TrialId {
        trialTypeExp = 1,
        trialTypeBook = 2,
        trialTypeHero = 3
    }

    export enum ShopId {
        foodToken = 1,
        forceToken = 2
    }

    export enum ResId {
        token = 2,
        silver = 1,
        exp = 3
    }

    export class ResVO {
        public item: ItemInfo;//物品信息
        public count: number;//数量
        public isSp: boolean = false;//是否是碎片
        public name: string;//名称
        public color: number = 0xFFF761;//文本颜色
        private _countTxt: string;//数量文本
        public quality: number = 0;//品质
        public description: string;//描述
        public isRandomDrop: boolean = false;//是否是随机掉落的
        public extNote: string = null;//额外的提示
        public grayed: boolean = false;//是否灰色显示
        public needShowMinus: boolean = true;//如果有减半效果是，是否需要显示

        public set countTxt(v) {
            this._countTxt = v;
        }

        public get countTxt(): string {
            if ((!this._countTxt) || (!this._countTxt.length))
                return this.count.toString();
            return this._countTxt;
        }

        public get showNameAsCount() {
            return (this.count == 1 && this.isSp == false && (this.item.itemType == ResType.hero || this.item.itemType == ResType.treasure || this.item.itemType == -1))
        }
    }
}